<template>
    <div class="index wh100">
        <transition name="slide-fade" class="wh100">
            <router-view :key="Number(new Date())"></router-view>
        </transition>
    </div>

</template>

<script>
export default {
    data () {
        return {
        };
    },

    mounted () {

        // this.height = window.screen.height
        document.getElementsByTagName('html')[0].style.height = (window.innerHeight) + 'px';
        sessionStorage.languageSet = 'zh-CN';
        this.$i18n.locale = 'zh-CN';
        this.initApp();
        this.getSystemInfo();
        this.getMenu();
    },

    methods: {
        // APP登录接口
        initApp () {
            let result = this.$route;
            if (!result.query.infokey) {
                return;
            }
            sessionStorage.menuActive = ''; // 导航菜单高亮
            localStorage.breadcrumbList = ''; // 面包屑导航
            localStorage.historicalList = ''; // 历史导航菜单
            sessionStorage.SRToken = 'Bearer ' + result.query.infokey;
            window.sessionStorage.userName = result.query.userName;
            this.loginUsername = result.query.userName;
            window.sessionStorage.setItem(
                'accessToken',
                'Bearer ' + result.query.infokey
            );
            window.localStorage.showDeclare = 'false';
            window.localStorage.ac_session = '';
            this.$store.dispatch('reflashSet');
            sessionStorage.personState = false;
            sessionStorage.roleName = result.query.roleName;
        },

        // 返回系统信息
        getSystemInfo () {
            this.$api.getSystemInfo().then(res => {
                if (res.data.code == 200) {
                    let data = res.data.data.systemPlatformInfo;
                    if (data) {
                        data = JSON.parse(data)

                        // console.log(data);
                        sessionStorage.setItem('versionInfo', data.Item2[1].Value)
                    }
                }
            })
        },
        
        // 获取菜单
        getMenu () {
            sessionStorage.menu = '';
            this.$api.GetMenus().then(res => {
                if (res.data.code == 200) {
                    let data = res.data.data
                    let result = data.filter((item, index) => {
                        return item.menuOwner == 2;
                    });
                    sessionStorage.menu = JSON.stringify(result);

                }
            }).catch(er => {
            })
        }
    }
};
</script>

<style lang="scss">
.index {
    // width: 100vw;
    // height: 100vh;
    // touch-action: pan-y !important;
    position: relative;

    .slide-fade-enter-active {
        transition: all 0.1s ease;
    }
    .slide-fade-leave-active {
        transition: all 0.1s cubic-bezier(1, 0.5, 0.8, 1);
    }
    .slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
        transform: translateX(10px);
        opacity: 0;
    }
}
</style>